
;(function () {

  var init = ()=> {
    bindEvent();
  }

  function bindEvent(){
    $('.js_form').submit(function(){return false; });
    $('.js_submit').click(handleSubmit);
  }

  function handleSubmit() {
    let codeValue = $('.js_textarea').text(),
        resultValue = $('.js-result').val(),
        problemTypeId = $('.js-problemTypeId').val(),
        pid = $('.js-pid').val(), //题目自定义id
        problemId = $('.js-id').val();  //题目表id

    $.ajax({
      url: '/user/submit-answer',
      method: 'post',
      data:{
        problem_answer: codeValue,
        submit_result: resultValue,
        problemTypeId,
        pid,
        problemId
      }
    })
  }

  init();
})();